import Router from 'koa-router'

const { univIdExist } = require('../middleware/univ.middleware')
const { auth } = require('../middleware/auth.middleware')
const { getUnivs, getUnivsByname, getUnivsByCity, getById, addUniv, updateUniv, deleteUniv } = require('../controller/univ.controller') 
const router = new Router({ prefix: '/orgs/univ' })

/**
 * 高校管理模块
 * @description univ
 */
router.get('/', getUnivs) // 获取所有高校(分页可选)
router.get('/searchUnivByUnivName', getUnivsByname) // 根据名字搜索高校(分页可选)
router.get('/searchUnivByUnivCity', getUnivsByCity) // 根据地区搜索高校(分页可选)
router.get('/:id', univIdExist, getById) // 根据id获取高校
router.post('/', auth, addUniv) // 添加高校
router.put('/:id', auth, univIdExist, updateUniv) // 更新高校
router.delete('/:id', auth, univIdExist, deleteUniv) // 删除高校

module.exports = router